package pdd;

import java.util.Arrays;
import java.util.Scanner;

public class T3 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] array = new int[n];
        int index = 0;
        while (index<n) {
            array[index++] = sc.nextInt();
        }
        Arrays.sort(array);
        double result = 0.0;

        if (m>=n) {
            for (int i : array) {
                result += i;
            }
            System.out.printf("%.1f", result);
            return;
        }

        // 读不完
        if ((n/2 + n%2) > m) {
            System.out.println(-1);
            return;
        }

        int readTogether = n-m;
        int readOnly = 2*m-n;
        int indexNow = 0;
        for(int i=0; i<readTogether; i++) {
            result += (array[indexNow] + array[indexNow+1])/2.0;
            indexNow += 2;
        }
        for (int i=0; i<readOnly; i++) {
            result += array[indexNow++];
        }
        System.out.printf("%.1f", result);
    }
}
